<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "https://www.w3.org/TR/html4/loose.dtd">
<html lang="zh-CN"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta http-equiv="Content-Language" content="zh-CN"><link href="stylesheet.css" media="all" rel="stylesheet" type="text/css">
<title>CLOSE</title>
<script> var _hmt = _hmt || []; (function() { var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?d286c55b63a3c54a1e43d10d4c203e75"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
</head><body class="REFENTRY">
<div>
<table summary="Header navigation table" width="100%" border="0" cellpadding="0" cellspacing="0">
<tr><th colspan="5" align="center" valign="bottom">PostgreSQL 8.2.3 中文文档</th></tr>
<tr><td width="10%" align="left" valign="top"><a href="sql-checkpoint.html" accesskey="P">后退</a></td><td width="10%" align="left" valign="top"><a href="sql-checkpoint.html">快退</a></td><td width="60%" align="center" valign="bottom"></td><td width="10%" align="right" valign="top"><a href="sql-cluster.html">快进</a></td><td width="10%" align="right" valign="top"><a href="sql-cluster.html" accesskey="N">前进</a></td></tr>
</table>
<hr align="LEFT" width="100%"></div>
<h1><a name="SQL-CLOSE"></a>CLOSE</h1>
<div class="REFNAMEDIV"><a name="AEN45664"></a><h2>名称</h2>CLOSE&nbsp;--&nbsp;关闭一个游标</div>
<a name="AEN45667"></a><a name="AEN45669"></a>
<div class="REFSYNOPSISDIV"><a name="AEN45672"></a><h2>语法</h2>
<pre class="SYNOPSIS">CLOSE <tt class="REPLACEABLE"><i>name</i></tt></pre>
</div>
<div class="REFSECT1"><a name="AEN45675"></a><h2>描述</h2>
<p><tt class="COMMAND">CLOSE</tt> 释放和一个游标关联的所有资源。不允许对一个已关闭的游标再做任何操作。一个不再使用的游标应该尽早关闭。</p>
<p>当创建游标的事务用 <tt class="COMMAND">COMMIT</tt> 或 <tt class="COMMAND">ROLLBACK</tt> 终止之后，每个不可保持的已打开游标都隐含关闭。当创建游标的事务通过 <tt class="COMMAND">ROLLBACK</tt> 退出之后，每个可以保持的游标都将隐含关闭。当创建游标的事务成功提交，那么可保持的游标保持打开，直到执行一个明确的 <tt class="COMMAND">CLOSE</tt> 或者客户端断开。</p>
</div>
<div class="REFSECT1"><a name="AEN45684"></a><h2>参数</h2>
<div class="VARIABLELIST">
<dl>
<dt><tt class="REPLACEABLE"><i>name</i></tt></dt>
<dd><p>一个待关闭的游标的名字</p></dd>
</dl>
</div>
</div>
<div class="REFSECT1"><a name="AEN45692"></a><h2>注意</h2>
<p>PostgreSQL 没有明确打开游标的 <tt class="COMMAND">OPEN</tt> 语句；认为一个游标在使用 <a href="sql-declare.html"><i>DECLARE</i></a> 语句声明的时候就打开了。</p>
<p>你可以通过查询系统视图 <tt class="STRUCTNAME">pg_cursors</tt> 看到所有可用的游标。</p>
</div>
<div class="REFSECT1"><a name="AEN45700"></a><h2>例子</h2>
<p>关闭游标 <tt class="LITERAL">liahona</tt> ：</p>
<pre class="PROGRAMLISTING">CLOSE liahona;</pre>
</div>
<div class="REFSECT1"><a name="AEN45705"></a><h2>兼容性</h2>
<p><tt class="COMMAND">CLOSE</tt> 与 SQL 标准完全兼容。</p>
</div>
<div class="REFSECT1"><a name="AEN45709"></a><h2>又见</h2><a href="sql-declare.html"><i>DECLARE</i></a>, <a href="sql-fetch.html"><i>FETCH</i></a>, <a href="sql-move.html"><i>MOVE</i></a></div>
<div>
<hr align="LEFT" width="100%">
<table summary="Footer navigation table" width="100%" border="0" cellpadding="0" cellspacing="0">
<tr><td width="33%" align="left" valign="top"><a href="sql-checkpoint.html" accesskey="P">后退</a></td><td width="34%" align="center" valign="top"><a href="index.html" accesskey="H">首页</a></td><td width="33%" align="right" valign="top"><a href="sql-cluster.html" accesskey="N">前进</a></td></tr>
<tr><td width="33%" align="left" valign="top">CHECKPOINT</td><td width="34%" align="center" valign="top"><a href="sql-commands.html" accesskey="U">上一级</a></td><td width="33%" align="right" valign="top">CLUSTER</td></tr>
</table>
</div>
</body></html>